<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.fick.hibernate.model.*"%>
<%@ page import="com.fick.hibernate.dao.*"%>
<%@ taglib uri="http://fckeditor.net/tags-fckeditor" prefix="FCK"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>栏目管理</title>
<style type="text/css">
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.STYLE1 {font-size: 12px;}
.STYLE4 {
	font-size: 12px;
	color: #1F4A65;
	font-weight: bold;
}

a:link {
	font-size: 12px;
	color: #06482a;
	text-decoration: none;

}
a:visited {
	font-size: 12px;
	color: #06482a;
	text-decoration: none;
}
a:hover {
	font-size: 12px;
	color: #FF0000;
	text-decoration: underline;
}
a:active {
	font-size: 12px;
	color: #FF0000;
	text-decoration: none;
}
.STYLE7 {font-size: 12px;}

</style>
<script type="text/javascript" src="js/meihuaxue.js"></script>
<script type="text/javascript" src="js/check.js"></script>
<script type="text/javascript">

 function sa(fatherid,fathername,channelid,name,order,url,isshow,img,nodecode){
 if(fathername=="顶级栏目"){
	 document.getElementById("upDate").style.display="none";
	 document.getElementById("addDate").style.display="";
	 document.getElementById("delDate").style.display="none";
 }else{
	 document.getElementById("upDate").style.display="";
	 document.getElementById("addDate").style.display="";
	 document.getElementById("delDate").style.display="";
 }
 document.getElementById('bigLeiName').value=fathername;
   document.getElementById("url").value=url;
   document.getElementById("selectLOGO").value=img;
   document.getElementById("but").value="add";
   document.getElementById("order").value=order;
   document.getElementById("addDate").value="添加下级栏目";
   document.getElementById("addDate").onclick=sb;
   document.getElementById("leiName").value=name;
   document.getElementById("xuhaoName").value=channelid;
   document.getElementById("channelid").value=channelid;
   document.getElementById("fatherid").value=fatherid;
   if(nodecode){
   var oEditor = FCKeditorAPI.GetInstance("describe") ; 
   oEditor.SetHTML(document.getElementById(nodecode).innerHTML) ;
   }
  if(isshow=="1")
    {document.getElementById("notshow").checked="true";}
    else
    {document.getElementById("show").checked="true";}
 }
 
 function sb(){
  
   
 document.getElementById("upDate").style.display="none";
 document.getElementById("addDate").style.display="";
 document.getElementById("delDate").style.display="none";
  document.getElementById("bigLeiName").value=document.getElementById("leiName").value;
   document.getElementById("upDate").onclick=error;
   document.getElementById("delDate").onclick=error;
   document.getElementById("addDate").value="添加";
   document.getElementById("addDate").onclick=sc;
   document.getElementById("leiName").value="";
   document.getElementById("order").value="";
   document.getElementById("selectLOGO").value="";
   document.getElementById("url").value="";
   document.getElementById("show").checked="true";
 }
 
 
 //添加按钮时触发
 function sc(){
     if(check()){
   document.getElementById("form1").submit();}
 }
 
 function error(){
   alert("添加下级栏目时不可用此按钮");
 }
 
 //当最底层栏目点击添加时
 function isclass(){
    alert("这是最底层栏目");
 }
 
 //当点击修改按钮时
 function up(){
   document.getElementById("but").value="update";
     if(check()){
    document.getElementById("form1").submit();}
 }
 
 //当点击删除按钮时
 function del(){
     document.getElementById("but").value="deldate";
     if(check()&& confirm('删除该栏目的同时栏目下所有信息也将删除，确实要删除该栏目吗?')){
     document.getElementById("form1").submit();}
 }
   function check(){ 
   	if(trim(document.form1.leiName.value)==""){
   		alert("请输入栏目名称!");
   		document.form1.leiName.focus();
   		return false;
   	}
   	if(trim(document.form1.order.value)!="" && document.form1.order.value!="0" && !isInt(document.form1.order.value,false)){
   		alert("请输入正确的顺序!");
   		document.form1.order.focus();
   		return false;
   	}
   	return true;
   }
</script>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="15" height="30"><img src="images/tab_03.gif" width="15" height="30" /></td>
        <td width="1101" background="images/tab_05.gif"><img src="images/311.gif" width="16" height="16" />
			<span class="STYLE4">栏目管理页面</span></td>
        <td width="281" background="images/tab_05.gif">
        &nbsp;
        </td>
        <td width="14"><img src="images/tab_07.gif" width="14" height="30" /></td>
      </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="9" background="images/tab_12.gif">&nbsp;</td>
        <td bgcolor="#f3ffe3">
         <form name="form1" id="form1" action="<%=request.getContextPath()%>/admin/managerNewLei.do?method=managerLei" method="post" >
	  <table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#D7DFE1">
        <tr>
          <td width="30%" height="25" align="center" valign="middle"  bgcolor="#FFFFFF"  class="STYLE1">栏目选择</td>
          <td width="70%" height="25" align="center" valign="middle"  bgcolor="#FFFFFF"  class="STYLE1">栏目管理</td>
        </tr>
        <tr>
          <td height="25"  valign="top" bgcolor="#FFFFFF"  class="STYLE1">
          <table width="98%" height="8" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td></td>
                </tr>
              </table>
              <table width="98%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td align="left" valign="top" class="STYLE1">				
					<script language="JavaScript">
                     var tree = new MzTreeView("tree");
                     tree.setIconPath("<%=request.getContextPath()%>/admin/TreeView/"); //可用相对路
                     tree.nodes["0_1"] = "text:栏目管理;method:sa('1','顶级栏目','','顶级栏目','','','','')";
					 <%
						ChannelDAO channeldao=new ChannelDAO();
					 List<Channel> channellist=channeldao.findAll();
					 for(int i=0;i<channellist.size();i++)
					 {Channel channel=(Channel)channellist.get(i);
					 int fatherid=channel.getFatherId();
					 String fathername="";
					 if(fatherid==1)
					 { fathername="无上级栏目";}
					 else{
						 Channel farChannel=channeldao.findById(fatherid);
						 if(farChannel!=null)
						 	fathername=farChannel.getName();
						 }
					 %> 
					   tree.nodes["<%=channel.getFatherId()%>_<%=channel.getChannelId()%>"] = "text:<%=channel.getName().replaceAll("'","‘").replaceAll("\"","”")%>;method:sa('<%=fatherid%>','<%=fathername.replaceAll("'","‘").replaceAll("\"","”")%>','<%=channel.getChannelId()%>','<%=channel.getName().replaceAll("'","‘").replaceAll("\"","”")%>','<%=""+channel.getShowOrder()%>','<%=channel.getUrl()%>','<%=channel.getIsShow()%>','<%=channel.getImg()==null?"":channel.getImg()%>','<%=channel.getFatherId()%>_<%=channel.getChannelId()%>')";  
					 <%
					   }
					 %>
					 
				   tree.setTarget("MzMain");
				   document.write(tree.toString());    //亦可用 obj.innerHTML = tree.toString();
				 </script>					
                      </td>
                  </tr>
                </table>
                <table width="98%" height="8" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td></td>
                  </tr>
                </table>
              
          </td>
          <td height="25" align="left" valign="top" bgcolor="#FFFFFF" style="padding-left:7px"   class="STYLE1">
          <table width="98%" height="8" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td>
                    <div style="display:none;">
                    <%
                    if(channellist!= null && channellist.size() > 0){
                    	for(Channel t : channellist){
                    		%>
                    		<div id='<%=t.getFatherId() + "_" + t.getChannelId() %>'>
                    		<%=t.getChdescribe()!= null ? t.getChdescribe() : "" %>
                    		</div>
                    		<%
                    	}
                    }
                    %>
                    </div>
                    </td>
                  </tr>
                </table>
          <table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#E7E6E6">
                    <tr>
                      <td width="30%" height="25" align="right" valign="middle" bgcolor="#FFFFFF" class="STYLE1">上级栏目：</td>
                      <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
					  <input name="bigLeiName" id="bigLeiName" type="text" class="ts_box3" readonly>
					  </td>
                    </tr>
                    <tr>
                      <td width="30%" height="25" align="right" valign="middle" bgcolor="#FFFFFF" class="STYLE1">栏目名称：</td>
                      <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
					  <input name="leiName" id="leiName" type="text" MAXLENGTH="50" class="ts_box3">
					  </td>
                    </tr>
                    <tr>
                      <td width="30%" height="25" align="right" valign="middle" bgcolor="#FFFFFF" class="STYLE1">栏目序号：</td>
                      <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
					  <input name="xuhaoName" id="xuhaoName" type="text" MAXLENGTH="50" class="ts_box3" readonly="true">
					  </td>
                    </tr>
                    <tr>
                      <td width="30%" height="25" align="right" valign="middle" bgcolor="#FFFFFF" class="STYLE1">栏目顺序：</td>
                      <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
					  <input name="order" id="order" type="text" class="ts_box3" MAXLENGTH="4">
					  </td>
                    </tr>
                    <tr>
                      <td width="30%" height="25" align="right" valign="middle" bgcolor="#FFFFFF" class="STYLE1">页面地址：</td>
                      <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
					  <input name="url" id="url" type="text" class="ts_box3" MAXLENGTH="500">
					  </td>
                    </tr>
                    <tr>
                      <td width="30%" height="25" align="right" valign="middle" bgcolor="#FFFFFF" class="STYLE1">栏目图片：</td>
                      <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
					<input id="selectLOGO" name="img" class="ts_box3" MAXLENGTH="500">
					<input type="button" value="浏览服务器" onclick="window.open('/admin/fckeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector','','width=600,height=400,left=200,top=200')" >
					  </td>
                    </tr>
                     <tr>
                      <td width="30%" height="25" align="right" valign="middle" bgcolor="#FFFFFF" class="STYLE1">是否显示：</td>
                      <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px" class="STYLE1">
					  <input name="isshow"  id="show" type="radio" value="0">显示&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					  <input name="isshow"  id="notshow"  type="radio" value="1">不显示
					  </td>
                    </tr>
                    <tr>
                      <td width="30%" height="25" align="right" valign="middle" bgcolor="#FFFFFF" class="STYLE1">栏目简介：</td>
                      <td height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
					  <FCK:editor id="describe" basePath="/admin/fckeditor/" height="200" toolbarSet="SimBasic">
		</FCK:editor>
					  </td>
                    </tr>
                    <tr>
                      <td height="30" colspan="2" align="center" valign="middle" bgcolor="#FFFFFF">
                       <input name="channelid" type="hidden" id="channelid" value="">
                   		<input name="fatherid" type="hidden" id="fatherid" value="">
					  <input type="hidden" value="" name="lei" id="lei">
					  <input type="hidden" value="" name="typeid" id="typeid">
					  <input type="hidden" value="" name="bigid" id="bigid">
					  <input type="hidden" value="" name="smallid" id="smallid">
					  <input type="hidden" value="managerLei" name="method" />
					  <input type="hidden" value="add" name="but" id="but" />
					  <input type="button" value="修改" name="upDate" id="upDate"  onclick="up()" style="display:none"/>
					  <input type="button" value="添加下级栏目" name="addDate" id="addDate" onClick="sb();"  style="display:none"/>
					  <input type="button" value="删除" name="delDate" id="delDate"  onclick="del()"  style="display:none"/>
					  </td>
                    </tr>
                  </table>
                  <table width="98%" height="8" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td></td>
                    </tr>
                </table>
          </td>
          </tr>
        </table>
        </form>
        </td>
        <td width="9" background="images/tab_16.gif">&nbsp;</td>
      </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td height="29">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="15" height="29"><img src="images/tab_20.gif" width="15" height="29" /></td>
        <td background="images/tab_21.gif">
        &nbsp;</td>
        <td width="14"><img src="images/tab_22.gif" width="14" height="29" /></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
<script type="text/javascript">
var message = "<%=session.getAttribute("message")%>";
if(message!=null && message!="null" && message !=""){
   alert(message);
  }
</script>
<%session.removeAttribute("message");%>
